<?php
/**
 * Created by PhpStorm.
 * User: 王飞
 * Date: 2017/9/8
 * Time: 22:56
 */
namespace app\index\controller;
use think\Controller;
use app\common\controller\WebFront;
use fast\third\Wechat;
use app\common\model\Userwechat;
use app\common\model\User;
use think\Exception;
use think\Session;
use app\common\model\Category;

class Myinterview extends Controller
{
	public function _initialize()
	{
		parent::_initialize();
	}
	public function getInterview(){
		$size=isset($_GET['size'])?$_GET['size']:10;
		$pagenum=isset($_GET['pagenum'])?$_GET['pagenum']:1;
		$total = db('worklog')->where('user_id',$_GET['userid'])
			->order('createtime')->where('w_type',3)
			->count();
		$data=db('worklog')->alias('w')->join('staff s','w.staff_id=s.id')
			->join('province p','s.province_id=p.id')
			->join('grade','s.grade_id=grade.id')
			->where('user_id',$_GET['userid'])
			->where('w_type',3)
			->limit($size)
			->order("'createtime' 'desc'")
			->field('s.id id,s.name name,s.avatar imgurl,s.serverdays_id date,p.name region,s.birthday age,w.facetype status,w.begintime createtime,w.createtime time,s.price price,s.tag summary,grade.name star')
			->page($pagenum)
			->select();
		foreach ($data as $key=>$value){
			$data[$key]['age']=birthday($data[$key]['age']);
		}
		$result = array("success"=>1,"total"=>$total,"data" => $data);
		return json($result);
	}
	
	public function mystaff(){
		$size=isset($_GET['size'])?$_GET['size']:10;
		$pagenum=isset($_GET['pagenum'])?$_GET['pagenum']:1;
		$total = db('worklog')->where('user_id',$_GET['userid'])
			->order('createtime')->where('w_type',2)
			->count();
		$data=db('worklog')->alias('w')->join('staff s','w.staff_id=s.id')
			->join('province p','s.province_id=p.id')
			->join('grade','s.grade_id=grade.id')
			->where('user_id',$_GET['userid'])
			->where('w_type',3)
			->limit($size)
			->order("'createtime' 'desc'")
			->field('s.id id,s.name name,s.avatar imgurl,s.serverdays_id date,p.name region,s.birthday age,w.facetype status,w.begintime createtime,w.createtime time,s.price price,s.tag summary,grade.name star')
			->page($pagenum)
			->select();
		foreach ($data as $key=>$value){
			$data[$key]['age']=birthday($data[$key]['age']);
		}
		$result = array("success"=>1,"total"=>$total,"data" => $data);
		return json($result);
	}
}